package com.xiangxiao.rpan.file;

import com.xiangxiao.rpan.file.factory.ApplicationContextFactory;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;

/**
 * @auther xiangxiao
 * @email 573768011@qq.com
 * @data 2023/5/29 11:02
 */
@SpringBootApplication(scanBasePackages = "com.xiangxiao.rpan.file", exclude = {FlywayAutoConfiguration.class, DataSourceAutoConfiguration.class})
@Configuration
@EnableEurekaClient
@EnableFeignClients
@EnableHystrix
@MapperScan("com.xiangxiao.rpan.file.dao")
@Slf4j
public class Application {
  private static Logger logger = LoggerFactory.getLogger(Application.class);
  public static void main(String[] args) throws Exception {
    try {
      ApplicationContext context = SpringApplication.run(Application.class, args);
      // 给ApplicationContextFactory的私有属性applicatio nContext赋值---Spring Ioc容器上下文
      ApplicationContextFactory.setApplicationContext(context);
    } catch (Throwable e) {
      logger.error("系统启动失败", e);
    }
  }
}
